# import docx
#
# doc = docx.Document()
#
# doc.add_paragraph('Hello world!')
#
# paraObj1 = doc.add_paragraph('This is a second paragraph.')
# #paraObj2 = doc.add_paragraph('This is a yet another paragraph.')
#
# #paraObj1.add_run('This text is being added to the second paragraph.')
#
# doc.save('multipleParagraphs.docx')


from datetime import datetime

import docx


class Text:  # 文本类
    def __init__(self):
        self.word = docx.Document()

    def addText(self):
        return self.word

    def saveText(self):
        # ../files/
        i = 0
        while True:
            self.word.add_paragraph('This is a new paragraph.')
            i += 1
            if i == 20:
                break
        str = datetime.now().strftime("./files/%Y-%m-%d-%H-%M")
        filename = str+'.docx'
        self.word.save(filename)
        return "Conference papers are saved"


if __name__ == '__main__':
    i = 0
    test = Text()
    test.addText()
    test.addText().add_heading('Meeting Notes', 0)
    while True:
        test.addText().add_paragraph('This is an new paragraph.',
                                      style='Subtitle'
                                      )

        # p.add_run('bold').bold = True
        # p.add_run(' and some ')
        # p.add_run('italic.').italic = True
        # run = test.addText().add_paragraph().add_run('This is an new paragraph.',
        #                             )
        # font = run.font
        # run.bold = True

        #font.name = '宋体'
        #font.size = Pt(12)
        i += 1
        if i == 4:
            break
    test.addText().add_page_break()
    test.addText().save("ex.docx")
print("Over")


